


import 'dart:math';

import 'package:bt_tool/basic/bt_model.dart';
import 'package:bt_tool/widget/pcList/bt_pc_list_head_model.dart';

class TranslateContentModel extends BTModel{

  int dataId = 0;
  int pid = 0;
  int createTime = 0;
  String key = "";
  String en = "";
  String ja = "";
  String ko = "";
  String fr = "";
  String es = "";
  String it = "";
  String de = "";
  String tr = "";
  String ru = "";
  String pt = "";
  String vi = "";
  String id = "";
  String th = "";
  String ms = "";
  String ar = "";
  String zhCN = "";
  String hi = "";
  bool isSel = false;
  int isHadExport = 0; //0:未导出，1：已经导出过了

  TranslateContentModel(super.oriJsonData);

  @override
  void parse() {
    super.parse();
    dataId = jsonTool.getInt("dataId");
    pid = jsonTool.getInt("pid");
    createTime = jsonTool.getInt("createTime");
    key = jsonTool.getString("key");
    en = jsonTool.getString("en");
    ja = jsonTool.getString("ja");
    ko = jsonTool.getString("ko");
    fr = jsonTool.getString("fr");
    es = jsonTool.getString("es");
    it = jsonTool.getString("it");
    de = jsonTool.getString("de");
    tr = jsonTool.getString("tr");
    ru = jsonTool.getString("ru");
    pt = jsonTool.getString("pt");
    vi = jsonTool.getString("vi");
    id = jsonTool.getString("id");
    th = jsonTool.getString("th");
    ms = jsonTool.getString("ms");
    ar = jsonTool.getString("ar");
    zhCN = jsonTool.getString("zhCN");
    isHadExport = jsonTool.getInt("isHadExport");
    hi = jsonTool.getString("hi");
  }

  @override
  Map<String, dynamic> convertToDict() {
    var map = super.convertToDict();
    map["dataId"] = dataId;
    map["pid"] = pid;
    map["createTime"] = createTime;
    map["key"] = key;
    map["en"] = en;
    map["ja"] = ja;
    map["ko"] = ko;
    map["fr"] = fr;
    map["es"] = es;
    map["it"] = it;
    map["de"] = de;
    map["tr"] = tr;
    map["ru"] = ru;
    map["pt"] = pt;
    map["vi"] = vi;
    map["id"] = id;
    map["th"] = th;
    map["ms"] = ms;
    map["ar"] = ar;
    map["zhCN"] = zhCN;
    map["isHadExport"] = isHadExport;
    map["hi"] = hi;
    return map;
  }

  bool checkIsNeedTranslate(List<BTPcListHeadModel> targetLanguageList){
    bool isNeed = false;
    for(var model in targetLanguageList){
      var dbKey = model.id;
      if(jsonTool.getString(dbKey).isEmpty){
        isNeed = true;
        break;
      }
    }
    return isNeed;
  }

}